﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Utils;

namespace Core
{
    public static class Cp
    {
        public static string GetSql(string cp, string name, string value) {
            string sql = "";
            switch (cp) {
                case "equal":
                    sql = Equal(name, value);
                    break;
                case "like":
                    sql = Like(name, value);
                    break;
            }
            return sql;
        }

        public static string Equal(string fieldName, string value) {
            return string.Format(" And {0} = '{1}'", fieldName, FilterSql.FilterValue(value));
        }
        public static string Like(string fieldName, string value) {
            return string.Format(" And {0} like '%{1}%'", fieldName, FilterSql.FilterValue(value));
        }
    }
}
